package com.example.testanimation;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.example.testanimation.javabean.User;


public class Login extends AppCompatActivity {

    private EditText meduser,medpassword;

    private MySQLiteOpenHelper1 mySQLiteOpenHelper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Compiler EdgeToEdge = null;
        EdgeToEdge.enable();
        setContentView(R.layout.activity_login);
        mySQLiteOpenHelper=new MySQLiteOpenHelper1(this);


        User user = new User();
        find();


    }
    public void find()
    {
        meduser=findViewById(R.id.ed_username_test1);
        medpassword=findViewById(R.id.ed_password_test2);

    }


    public void login(View view)
    {
        String s1 = meduser.getText().toString();
        String s2 = medpassword.getText().toString();
        boolean login = mySQLiteOpenHelper.login(s1, s2);

        if(login)
        {
            String message = meduser.getText().toString();
            Toast.makeText(this, "登录成功", Toast.LENGTH_SHORT).show();
            Intent intent = new Intent(Login.this, Self.class);
            intent.putExtra("message_key", message);
            startActivity(intent);

        }
        else {
            Toast.makeText(this, "登录失败,请输入正确的用户名和密码", Toast.LENGTH_SHORT).show();

        }



    }

    public void zhuce(View view)
    {
        Intent intent = new Intent(Login.this, Sign.class);
        startActivity(intent);

    }



}